package com.feign;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 创建可访问的
 */
@RefreshScope
@RestController
public class ConsumerController {

    @Autowired
    ComputeClient computeClient;

    @Value("${from}")
    private String from;


    @RequestMapping(value = "/add", method = RequestMethod.GET)
    public Integer add() {
        return computeClient.add(10, 20);
    }

    /**
     * 获取配置中心的值
     * @return
     */
    @RequestMapping(value = "/config", method = RequestMethod.GET)
    public String getConfig() {
        return from;
    }
}
